

#import "ConsoleManager.h"
#import "Imports.h"

@implementation ConsoleManager

- SetMeterTo: ThisSound
{
		[Meter setSound: ThisSound];
		[Meter lockFocus];
		[Meter run:self];
		return self;
}

- PlayDown:sender
{
    if (	([TheFileController CurrentWindow:self]!=NULL)&&
    		(! [TheSoundManager IsPlaying])&&
		(! [TheSoundManager IsRecording])    )
	{	
	[TheSoundManager Play:self];
	}
    else
    	{
		[PlayButton setState:(![PlayButton state])];
	}

    return self;
}

- LeftSoundUp:sender
{
    float left;
    float right;
    
    [Sound getVolume:&left:&right];
    if 	(left<=.9)
      	{left+=.1;}
    else
    	{left=1.0;}
    [Sound setVolume:left:right];
    return self;
}

- RightSoundUp:sender
{
    float left;
    float right;
    
    [Sound getVolume:&left:&right];
    if 	(right<=.9)
      	{right+=.1;}
    else
    	{right=1.0;}
    [Sound setVolume:left:right];
    return self;

}

- LeftSoundDown:sender
{
    float left;
    float right;
    
    [Sound getVolume:&left:&right];
    if 	(left>=.1)
      	{left-=.1;}
    else
    	{left=0.0;}
    [Sound setVolume:left:right];
    return self;
}

- RightSoundDown:sender
{
    float left;
    float right;
    
    [Sound getVolume:&left:&right];
    if 	(right>=.1)
      	{right-=.1;}
    else
    	{right=0.0;}
    [Sound setVolume:left:right];
    return self;
}


- RecordDown:sender
{
    if (	(! [TheSoundManager IsPlaying])&&
		(! [TheSoundManager IsRecording]))
		{	
		if ([TimedRecordButton intValue])
			{
			if ([FortyMonoButton intValue])
				{
				[TheSoundManager Record: SND_RATE_HIGH: (int) 1: [SecondsField intValue]: sender];
				}
			else if ([FortyStereoButton intValue])
				{
				[TheSoundManager Record: SND_RATE_HIGH: (int) 2: [SecondsField intValue]: sender];
				}
			else if ([TwentyMonoButton intValue])
				{
				[TheSoundManager Record: SND_RATE_LOW: (int) 1: [SecondsField intValue]: sender];
				}
			else if ([TwentyStereoButton intValue])
				{
				[TheSoundManager Record: SND_RATE_LOW: (int) 2: [SecondsField intValue]: sender];
				}
			else if ([MuLawButton intValue])
				{
				[TheSoundManager Record: SND_RATE_CODEC: (int) 1: [SecondsField intValue]: sender];
				}
			}
		else
			{
			if ([FortyMonoButton intValue])
				{
				[TheSoundManager Record: SND_RATE_HIGH: (int) 1: 0: sender];
				}
			else if ([FortyStereoButton intValue])
				{
				[TheSoundManager Record: SND_RATE_HIGH: (int) 2: 0: sender];
				}
			else if ([TwentyMonoButton intValue])
				{
				[TheSoundManager Record: SND_RATE_LOW: (int) 1: 0: sender];
				}
			else if ([TwentyStereoButton intValue])
				{
				[TheSoundManager Record: SND_RATE_LOW: (int) 2: 0: sender];
				}
			else if ([MuLawButton intValue])
				{
				[TheSoundManager Record: SND_RATE_CODEC: (int) 1: 0: sender];
				}
			}
	}
    else
    	{
		[RecordButton setState:(![RecordButton state])];
	}

	return self;
}

- StopDown:sender
{
    [TheSoundManager Stop:self];
    [RecordButton setState:0];
    [PlayButton setState:0];
    [StopButton setState:0];
    return self;
}

-TurnOffPlay
{
    [Meter stop:self];
    [PlayButton setState:0];
    return self;
}

- TurnOffRecord
{
    [Meter stop:self];
    [RecordButton setState:0];
    return self;
}


@end
